package com.zhangzhan.controller;

import com.zhangzhan.domain.commcon.ResponseResult;
import com.zhangzhan.domain.dto.SaveTagDto;
import com.zhangzhan.domain.dto.TagListBQDto;
import com.zhangzhan.domain.vo.TagVO;
import com.zhangzhan.domain.vo.PageVO;
import com.zhangzhan.service.TagService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/content/tag")
public class TagController {
    @Autowired
    private TagService tagService;

    /*@GetMapping("/list")
    public ResponseResult list(){
        return ResponseResult.okResult(tagService.list());
    }*/
    /**
     * @description 分页查询标签
     * @param pageNum
     * @param pageSize
     * @param vo
     * @return com.zhangzhan.domain.commcon.ResponseResult
     * @author 31115
     * @date 2022/12/6 14:29
     */
    @GetMapping("/list")
    public ResponseResult<PageVO> list(Integer pageNum, Integer pageSize, TagListBQDto vo){

        return tagService.selectPageList(pageNum,pageSize,vo);
    }

    /**
     * @description 新增接口
     * @param saveTagDto
     * @return com.zhangzhan.domain.commcon.ResponseResult
     * @author 31115
     * @date 2022/12/6 15:17
     */
    @PostMapping
    public ResponseResult saveTag(@RequestBody SaveTagDto saveTagDto){
        return tagService.saveTag(saveTagDto);
    }

    /**
     * @description 删除接口
     * @param id
     * @return com.zhangzhan.domain.commcon.ResponseResult
     * @author 31115
     * @date 2022/12/6 15:23
     */
    @DeleteMapping("{id}")
    public ResponseResult deleteTag(@PathVariable Long id){
        return tagService.deleteTag(id);
    }

    /**
     * @description 修改前回显
     * @param id
     * @return com.zhangzhan.domain.commcon.ResponseResult
     * @author 31115
     * @date 2022/12/6 15:34
     */
    @GetMapping("{id}")
    public ResponseResult updateTag(@PathVariable Long id){
        return tagService.updateTag(id);
    }

    /**
     * @description 修改
     * @param tagDto
     * @return com.zhangzhan.domain.commcon.ResponseResult
     * @author 31115
     * @date 2022/12/6 15:53
     */
    @PutMapping
    public ResponseResult updateTag(@RequestBody TagListBQDto tagDto){
        return tagService.updateTagNow(tagDto);
    }

    @GetMapping("/listAllTag")
    public ResponseResult<TagVO> listAllTag(){
        return tagService.listAllTag();
    }
}

